<?php
/**
 * 信息提示
 * @author Ice<iceinto@mallog.com.cn>
 */
class TipAction extends CommonAction
{
    function _initialize()
    {
    }

    public function index()
    {

    }

    /**
     * Judge whether there is demand returned task
     *
     * @author Ice<iceinto@mallog.com.cn>
     */
    public function taskReturn()
    {
        $uid = $this->getLoginUserInfo();
        if ($uid) {
            $status = 0;
            $count = array();
            $QueueModel = D('Queue');
            $mid = $this->_mall[0]['mid'];
            $count ['returnNum'] = $QueueModel->getCreatorStatusCount($uid, 4, $mid);
            $count ['waitingNum'] = D('Task')->getStatusCount(1, $uid, $mid);
            if (!empty($count ['returnNum'])) {
                $status = 1;
            }
            $this->ajaxReturn($count, null, $status);
        }
    }

    /**
     * Evaluate whether need to audit task
     *
     * @author Ice<iceinto@mallog.com.cn>
     */
    public function audit()
    {
        $status = 0;
        $uid = $this->getLoginUserInfo();
        if ($uid) {
            $count = $this->getQueueStatusCount(6, $uid);
            if ($count > 0) {
                $status = 1;
            } else {
                $count = $this->getQueueStatusCount(6, 0);
                if ($count > 0) {
                    $status = 1;
                }
            }
            $this->ajaxReturn($count, null, $status);
        }
    }

    /**
     * Return Queue count
     *
     * @param $map array
     * @author Ice<iceinto@mallog.com.cn>
     */
    private function getQueueStatusCount($status, $auditor)
    {
        $map = array();
        $map ['status'] = $status;
        $map ['auditor'] = $auditor;
        return M('Queue')->where($map)->count();
    }
}

?>